﻿namespace IBTrader.Indicator.Oscillator
{
    using IBTrader.Modules.Read;
    using IBTrader.Charts;

    /// <summary>
    /// Developed by Tushard Chande and Stanley Kroll, StochRSI is an oscillator that measures the level of RSI relative to its high-low range over a set time period. 
    /// StochRSI applies the Stochastics formula to RSI values, instead of price values. This makes it an indicator of an indicator. 
    /// The result is an oscillator that fluctuates between 0 and 1.
    /// </summary>
    class StochRSI : BasePrices
    {
        internal StochRSI(Worker worker, int interval = 20) : base(null, new ChartArgs { Group = 1 }, interval)
        {
            new RSI(worker, interval).Hit += Add;
        }
        public override void Add(object _, Line line)
        {
            Prices.Add(line.Price);
            OnHit(line, NaN(Stochastic.Relative(Prices)));
        }
    }
}